<#import "/spring.ftl" as spring />
<html>
<head>

</head>
<body>

<div id="content">

	<h1>INVOICE PAYMENT</h1>

	<#if paymentRequest??>
		<p>The following invoices have not been paid</p>
		<#assign paymentTotal = 0 />
		<table>
		<tr>
			<th>Month</th>
			<th>Amount</th>
		</tr>
		<#list invoices as invoice>
			<tr>
				<td>${invoice.invoicePeriodStartDate?string("MMMM yyyy")}</td>
				<td>$${invoice.calculateInvoiceAmount()}</td>
			</tr>
			<#assign paymentTotal = paymentTotal + invoice.calculateInvoiceAmount() />
		</#list>
		<tr>
			<td>TOTAL</td>
			<td>$${paymentTotal}</td>
		</tr>		
		</table>
	<#else>
		<p>You have no unpaid invoices at this time.</p>
	</#if>
	
	<#if paymentRequest??>
		
		<table>
		<tr>
			<td>
				<form action="${paymentRequest.paymentGatewayUrl}" method="post">
					<INPUT type='hidden' name='x_login' value='${paymentRequest.loginId}' />
					<INPUT type='hidden' name='x_amount' value='${paymentRequest.amount}' />
					<INPUT type='hidden' name='x_description' value='${paymentRequest.description}' />
					<INPUT type='hidden' name='x_invoice_num' value='${paymentRequest.invoiceNumber}' />
					<INPUT type='hidden' name='x_fp_sequence' value='${paymentRequest.sequenceNumber?c}' />
					<INPUT type='hidden' name='x_fp_timestamp' value='${paymentRequest.timestamp?c}' />
					<INPUT type='hidden' name='x_fp_hash' value='${paymentRequest.fingerprint}' />
					<INPUT type='hidden' name='x_test_request' value='${paymentRequest.testMode?string}' />
					<INPUT type='hidden' name='x_show_form' value='PAYMENT_FORM' />
					
					<INPUT type='hidden' name='x_first_name' value='${employee.name.first}' />
					<INPUT type='hidden' name='x_last_name' value='${employee.name.last}' />
					<INPUT type='hidden' name='x_company' value='${employee.company.name}' />
					<INPUT type='hidden' name='x_address' value='${employee.company.address.street1}' />
					<INPUT type='hidden' name='x_city' value='${employee.company.address.city}' />
					<INPUT type='hidden' name='x_state' value='${(employee.company.address.state)!}' />
					<INPUT type='hidden' name='x_zip' value='${employee.company.address.zipCode}' />
					<INPUT type='hidden' name='x_country' value='US' />
					<INPUT type='hidden' name='x_phone' value='${employee.phone}' />
					<#--INPUT type='hidden' name='x_fax' value='${employee.fax}' /-->
					<INPUT type='hidden' name='x_email' value='${employee.email}' />
					
					<INPUT type='hidden' name='x_ship_to_first_name' value='${employee.name.first}' />
					<INPUT type='hidden' name='x_ship_to_last_name' value='${employee.name.last}' />
					<INPUT type='hidden' name='x_ship_to_company' value='${employee.company.name}' />
					<INPUT type='hidden' name='x_ship_to_address' value='${employee.company.address.street1}' />
					<INPUT type='hidden' name='x_ship_to_city' value='${employee.company.address.city}' />
					<INPUT type='hidden' name='x_ship_to_state' value='${(employee.company.address.state)!}' />
					<INPUT type='hidden' name='x_ship_to_zip' value='${employee.company.address.zipCode}' />
					<INPUT type='hidden' name='x_ship_to_country' value='US' />
			
					<input type='submit' value='PAY WITH CREDIT CARD' />
				</form>
			</td>
			<td>&nbsp;</td>
			<td align="center">
				<!-- (c) 2005, 2009. Authorize.Net is a registered trademark of CyberSource Corporation --> 
				<div class="AuthorizeNetSeal"> 
					<script type="text/javascript" language="javascript">
						var ANS_customer_id="1f6186ad-b337-43fb-9dca-bd56055b25e5";
					</script> 
					<script type="text/javascript" language="javascript" src="//verify.authorize.net/anetseal/seal.js" >
					</script> 
					<a href="http://www.authorize.net/" id="AuthorizeNetText" target="_blank">Online Payments</a> 
				</div>
			</td>	
		</tr>
		</table>
		 
	</#if>
</div>

</body>
</html>
